﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Funnel60mm : BaseBrokenObj
{
    public GameObject m_Target;
    public GameObject m_BigTarget;
    public FunnelBottom m_MyBottom;

    public bool OnPlatfrom;
    public override void OnReleseTrigger(NoloDeviceType handleType)
    {
        if (!OnPlatfrom)
        {
            base.OnReleseTrigger(handleType);
            transform.SetParent(m_BigTarget.transform);
        }
        else
        {
            SetOnPlatfrom();//放置到铁架台上
        }
        isCatch = false;
    }
    public void SetOnPlatfrom()
    {
        m_rigidbody.useGravity = false;
        m_rigidbody.isKinematic = true;
        transform.position = m_Target.transform.position;
        transform.SetParent(m_Target.transform);
        StepsManager.Instance.StepThreeNum[0] = true;
        StepsManager.Instance.SetStepThree(0);
    }

    private void LateUpdate()
    {
        if (Vector3.Distance(m_Target.transform.position, transform.position) < 0.1f)
        {
            OnPlatfrom = true;
        }
        else
        {
            OnPlatfrom = false;
        }

        if (OnPlatfrom)
        {
            if (m_MyBottom.OnWall1)
            {
                StepsManager.Instance.StepThreeNum[1] = true;
                StepsManager.Instance.SetStepThree(1);
            }

            if (m_MyBottom.OnWall2)
            {
                StepsManager.Instance.StepThreeNum[2] = true;
                StepsManager.Instance.SetStepThree(2);
            }
        }
    }

    int ClearNum;
    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "BeakerBrush")
        {
            if (StepsManager.Instance.StepFourNum[1])
            {
                if (!StepsManager.Instance.StepFiveNum[4])
                {
                    ClearNum++;
                    if (ClearNum == 2)
                    {
                        StepsManager.Instance.StepFiveNum[4] = true;
                        StepsManager.Instance.SetStepFive(4);
                    }
                }
            }
        }

    }
}
